package com.yungui.kafka.consumer.es;

import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;

public class EsQueryUtil {

    public static BoolQueryBuilder wildcardQueryMultiValue(String column, String keyword) {
        BoolQueryBuilder wildcard_query = QueryBuilders.boolQuery();
        wildcard_query.should(QueryBuilders.termQuery(column, keyword.trim()));
        wildcard_query.should(QueryBuilders.wildcardQuery(column, String.format("%s,*", keyword.trim())));
        wildcard_query.should(QueryBuilders.wildcardQuery(column, String.format("*,%s,*", keyword.trim())));
        wildcard_query.should(QueryBuilders.wildcardQuery(column, String.format("*,%s", keyword.trim())));
        return wildcard_query;
    }
}
